<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>类目编辑</title>
    <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/layui@2.6.8/dist/css/layui.css">
    <script src="//cdn.jsdelivr.net/npm/layui@2.6.8/dist/layui.js" charset="utf-8"></script>
</head>
<body>
    <div style="margin: 15px;padding: 15px;background-color: #fff">
        <div class="layui-form">
            <input type="hidden" name="pid" value="{$pid}">
            <div class="layui-form-item">
                <label for="title" class="layui-form-label">类目名称</label>
                <div class="layui-input-block">
                    <input type="text" name="title" id="title" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" onclick="save()">提交</button>
                </div>
            </div>
        </div>
    </div>

    <script>
        var $ = layui.jquery;
        function save() {
            var pid = $('input[name="pid"]').val(),
                title = $('input[name="title"]').val();
            $.post('/admins/products/cate_save', {pid, title}, function(res){
                if (res.code) return layer.alert(res.msg, {icon: 2});
                layer.alert(res.msg, {icon: 1});
                setTimeout(function(){
                    parent.window.location.reload();
                }, 1000);
            }, 'json');
        }
    </script>
</body>
</html>